<?php
// +----------------------------------------------------------------------
// | KITEGO-Admin「开箱即用」「人人全栈」
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2024 https://www.kitego.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed KITEGO并不是自由软件，未经许可不能去掉KITEGO相关版权
// +----------------------------------------------------------------------
// | Author: KITEGO Team <bd@kitego.cn>
// +----------------------------------------------------------------------

namespace kitego\enums;

final class AttachmentEnum
{
    private function __construct() {} // 防止实例化

    const FILE_UPLOAD_SOURCE_ADMIN = 1; // [1-后台]
    const FILE_UPLOAD_SOURCE_USER = 2; // [2-用户]
    const FILE_UPLOAD_TYPE = ['image', 'file', 'video']; // 附件上传类型

    const FILE_IMAGE = 1; // 图片上传类型
    const FILE_VIDEO = 2; // 视频上传类型
    const FILE_FILE = 3; // 文件上传类型

    const FILE_IMAGE_EXT = ['jpg', 'png', 'gif', 'jpeg', 'webp', 'ico']; // 图片后缀
    const FILE_VIDEO_EXT = ['wmv', 'avi', 'mpg', 'mpeg', '3gp', 'mov', 'mp4', 'flv', 'f4v', 'rmvb', 'mkv']; // 视频后缀
    const FILE_FILE_EXT = ['zip', 'rar', 'txt', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'csv', 'txt', 'ftr', '7z', 'gz']; // 文件后缀

    public static function getFileUploadType($type)
    {
        if ($type == 'image') return self::FILE_IMAGE;
        if ($type == 'video') return self::FILE_VIDEO;
        if ($type == 'file') return self::FILE_FILE;

        exception('未知文件上传类型');
    }

    public static function getFileUploadExt($type)
    {
        if ($type == 'image') return self::FILE_IMAGE_EXT;
        if ($type == 'video') return self::FILE_VIDEO_EXT;
        if ($type == 'file') return self::FILE_FILE_EXT;

        exception('未知文件上传类型');
    }
}